﻿using System.Runtime.Serialization;
using System;

namespace NIGeoCoding
{
  [Serializable]
  [DataContract]
  public class Placemark
  {
    public string Country
    {
      get { return this.AddressDetails.Country.CountryNameCode; }
    }

    public string State
    {
      get { return this.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName; }
    }

    public string City
    {
      get
      {
        if (this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null)
          return this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
        return string.Empty;
      }
    }

    public string PostalCode
    {
      get 
      {
        if (this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null) 
          return this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
        return string.Empty;
      }
    }

    public string StreetAddress
    {
      get 
      {
        if(this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null)
          return this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
        return string.Empty;
      }
    }

    public string County
    {
      get 
      {
        if (this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null) 
          return this.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
        return string.Empty;
      }
    }

    [DataMember]
    public string id { get; set; }
    [DataMember]
    public string address { get; set; }
    [DataMember]
    public AddressDetails AddressDetails { get; set; }
    [DataMember]
    public ExtendedData ExtendedData { get; set; }
    [DataMember]
    public Point Point { get; set; }
  }
}
